<?php

namespace App\Admin\Controllers;

use App\Admin\Forms\Settings;
use App\Services\DashboardService;
use Encore\Admin\Widgets\Tab;
use App\Http\Controllers\Controller;
use App\Services\StatisticServer;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Content;


class HomeController extends Controller
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '工作台';

    protected $statisticServer;
    protected $dashboardService;

    public function __construct(DashboardService $dashboardService, StatisticServer $statisticServer)
    {
        $this->dashboardService = $dashboardService;
        $this->statisticServer = $statisticServer;
    }

    public function index(Content $content)
    {

        $user = Admin::user();
        return $content
            ->title($this->title)
            ->description('  ')
            ->row($this->statisticServer->patent2())
            ->row($this->statisticServer->patent($user, 1))
            ->row($this->dashboardService->transverseCharts());
    }

    public function settings(Content $content)
    {
        return $content
            ->title('系统设置')
            ->body(Tab::forms([
                'basic'   => Settings\BaseInfo::class,
                'login'   => Settings\LoginSetting::class,
                'sync'    => Settings\SyncSetting::class,
                'patent'  => Settings\PatentSetting::class,
                'project' => Settings\ProjectSetting::class,
                'module'  => Settings\ModuleSetting::class,
            ]));
    }
}
